﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using PoolGame2.Assets;
using PoolGame2.Physics;
using PoolGame2.Menus;
using PoolGame2.Player;
using PoolGame2.Networking;
using PoolGame2.Managers;
using PoolGame2.Controls;
using PoolGame2.Game;

namespace PoolGame2.Rules
{
    class BallRules : RuleC
    {
        PoolGame Game;

        public BallRules(PoolGame game)
        {
            this.Game = game;
        }

        // No need for checking ball-ball collisons if the ball isn't cue

        public override RulesEnum CheckRules(Ball ball)
        {
            PlayerPresence playerPres = Game.gameManager.GetPlayerPresence();
            if (!playerPres.getStripes() && !playerPres.getColours() && ball.getPocketed() && ball.getVisible() == true){
                //Legal - Special case - neither stripes nor colours
                if (ball.getNumber() < 8)
                {
                    return RulesEnum.POT_COLOUR_FIRST; //Return colour
                }
                else if (ball.getNumber() > 8)
                {
                    return RulesEnum.POT_STRIPE_FIRST; //Return stripe
                }
            }
            else if (ball.getNumber() < 8 && playerPres.getColours() && ball.getPocketed() && ball.getVisible() == true)
            {
                //Ball pocketed, legal
                return RulesEnum.POT_VALID;
            }
            else if (ball.getNumber() > 8 && playerPres.getStripes() && ball.getPocketed() && ball.getVisible() == true)
            {
                //Ball pocketed, legal
                return RulesEnum.POT_VALID;
            }
            else if (ball.getVisible() == true)
            {
                //Ball pocketed, illegal
                return RulesEnum.POT_INVALID;
            }

            return RulesEnum.ERROR; //Ball was not potted
        }
        public override RulesEnum CheckRules(Ball ball1, Ball ball2)
        {
            throw new NotImplementedException();
        }
    }
}
